import Base from 'models/base';

export default class LoginPassword extends Base {
  username = '';
  password = '';
  userPhone = '';
  phoneCode = '';
  confirmPassword = '';

  constructor() {
    super();
  }

  checkValid() {
    let fields = ['username', 'userPhone', 'password', 'confirmPassword', 'phoneCode'];
    let code = this.checkRequired(fields);
    if (code !== '') {
      return code;
    }

    if (this.password !== this.confirmPassword) {
      return 'password!==confirmPassword';
    }

    return '';
  }

  getObject() {
    let postData = {
      username: this.username,
      password: this.password,
      phoneCode: this.phoneCode,
      userPhone: this.userPhone
    };
    return postData;
  }
}
